/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import util.HibernateUtil;

/**
 *
 * @author Nguyen Trung
 */
public class DataConnection {
    private Session session;
    
    public DataConnection()
    {
        SessionFactory factory = HibernateUtil.getSessionFactory();
       session = factory.getCurrentSession();
    }
    public void connect()
    {
       
        getSession().beginTransaction();
    }
    public void close()
    {
         getSession().flush();
         getSession().getTransaction().commit();
    }

    /**
     * @return the session
     */
    public Session getSession() {
        return session;
    }

    /**
     * @param session the session to set
     */
    public void setSession(Session session) {
        this.session = session;
    }
}
